define(function () {
    /*  屏幕对象（方法）*/
    function adoptScreen() {
        let nodeArr = [document.querySelectorAll(".cont")[0], document.querySelectorAll(".cont")[1], document.querySelectorAll(".cont")[2]],
            sharePare = document.querySelectorAll(".right-inner")[0],
            length,
            width
        if (sharePare.offsetWidth > 1280) {
            width = 380
            length = 3
        } else if (sharePare.offsetWidth > 840) {
            width = 380
            length = 2
        } else {
            width = sharePare.offsetWidth - 24 - 17
            if (width > 380) {
                width = 380
            }
            length = 1
        }
        for (let i = 0; i < nodeArr.length; i++) {
            nodeArr[i].style.width = width + "px"
        }
        return length
    }

    function getMinHeight(NodeClassName) {
        let list = document.querySelectorAll("." + NodeClassName)[0].children
        let minHeight = 100000000
        let tempHeight = 0;
        for (let index = 0; index < list.length; index++) {
            if (list[index].style.display !== "none") {
                if (document.getElementsByTagName("body")[0].clientHeight > list[index].lastChild.clientHeight) {
                    tempHeight = document.getElementsByTagName("body")[0].clientHeight
                } else {
                    tempHeight = list[index].lastChild.clientHeight
                }
                if ((list[index].clientHeight - tempHeight ) < minHeight) {
                    minHeight = list[index].clientHeight - tempHeight
                }
            }
        }
        return minHeight
    }

    function removeChildrenNodes(pName, array) {
        let pareNode = document.querySelectorAll("." + pName)[0]
        for (let i = 0; i < array.length; i++) {
            removeNode(pareNode, array[i])
        }
    }

    function removeNode(node, point) {
        for (let i = 0; i < node.children.length; i++) {
            if (node.children[i] === point) {
                node.removeChild(point)
                return
            } else {
                removeNode(node.children[i], point)
            }
        }
    }

    function getAllNextChildNode(pName) {
        let firstRank = document.querySelectorAll("." + pName)[0],
            arrayAllParentNode = [],
            arrayAllChildrenNode = [],
            flag = false,
            addShare = false
        //判断是否有addShare节点 不删除添加节点
        if (firstRank.children[0] && firstRank.children[0].children[0] && firstRank.children[0].children[0].className === "cont-inner addShare") {
            flag = true
        }
        for (let i = 0; i < firstRank.children[0].children.length; i++) {
            if (flag) {
                for (let j = 0; j < firstRank.children.length; j++) {
                    if (j === 0) {
                        if (firstRank.children[j].children[i + 1])
                            arrayAllChildrenNode.push(firstRank.children[j].children[i + 1])
                    } else {
                        if (firstRank.children[j].children[i])
                            arrayAllChildrenNode.push(firstRank.children[j].children[i])
                    }
                }
            } else {
                for (let j = 0; j < firstRank.children.length; j++) {
                    if (firstRank.children[j].children[i])
                        arrayAllChildrenNode.push(firstRank.children[j].children[i])
                }
            }
        }
        return {
            arrayAllChildrenNode: arrayAllChildrenNode,
            addShare: flag
        }
    }

    return {
        adoptScreen,
        getMinHeight,
        removeChildrenNodes,
        getAllNextChildNode
    }
})